package com.veetao.api.resp;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;

public class ListDataResp<T> extends CommonResultResp {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3676216510860045106L;
	private ListDataContainer<T> data;

	public ListDataResp(List<T> list, int pageNo, int totalCount) {
		super();
		this.data = new ListDataContainer<T>();
		this.data.setList(list);
		this.data.setCurrentPageNo(pageNo);
	}
		
	public ListDataResp(List<T> list, int pageNo) {
		super();
		this.data = new ListDataContainer<T>();
		this.data.setList(list);
		this.data.setCurrentPageNo(pageNo);
	}
	
	

	
	public ListDataContainer<T> getData() {
		return data;
	}

	public void setData(ListDataContainer<T> data) {
		this.data = data;
	}

	public void setList(List<T> list, int pageNo) {
		this.data.setList(list);
		this.data.setCurrentPageNo(pageNo);
	}
	
	public ListDataResp() {
		super();
		this.data = new ListDataContainer<T>();
	}
	
	public void putExtra(String key, long value) {
		if( this.data == null ) {
			throw new IllegalStateException("Data must be initialized first");
		}
		this.data.putExtra(key, value+"");
	}
	
	public void putExtra(String key, String value) {
		if( this.data == null ) {
			throw new IllegalStateException("Data must be initialized first");
		}
		this.data.putExtra(key, value);
	}

	@JsonIgnore
	public Map<String, String> getExtraMap() {
		if(data == null) {
			return null;
		}
		return this.data.getExtraMap();
	}
	
	
	
}
